var blogModule=new Object({
    //加载新闻
    loadNews : function (){
                $.ajax({
                    url : '/front/queryNewsByNomal',
                    type : 'post',
                    dataType : 'json'
                }).done(function(data){
                    if(data){
                        $('#fh5co-blog .news').empty();
                        for(var i=0;i<data.length;i++){
                            var date=getDateObject(data[i].pubDate);
                            var divHtml='<div class="col-md-4 animate-box fadeInUp animated-fast">'+
                                '<div class="fh5co-event">'+
                                '<div class="date text-center"><span>'+date.day+'<br />'+date.month+'</span></div>'+
                                '<h3><a href="#">'+data[i].title+'</a></h3>'+
                                '<p class="text-ellipsis">'+data[i].description+'</p>'+
                                '<p><a href="/front/newsDetail.html?id='+data[i].id+'">查看详情</a></p>'
                            '</div>'+
                            '</div>';
                            $('#fh5co-blog .row-padded-mb').append(divHtml);
                        }
                    }
                })
            },
    //加载动态信息
    loadDynamic : function(){
                    $.ajax({
                        url: '/front/queryDynamicByNormal',
                        type: 'post',
                        dataType: 'json'
                    }).done(function (data) {
                        if (data) {
                            $('#fh5co-blog .dynamic').empty();
                            for (var i = 0; i < data.length; i++) {
                                var dy_html = '<div class="col-lg-4 col-md-4">' +
                                    '<div class="fh5co-blog animate-box fadeInUp animated-fast">' +
                                    '<a href="#" class="blog-img-holder" style="background-image: url(' + data[i].picture + ');"></a>' +
                                    '<div class="blog-text">' +
                                    '<h3><a href="#">' + data[i].title + '</a></h3>' +
                                    '<span class="posted_on">' + data[i].dynDate + '</span>' +
                                    '<p class="text-ellipsis">' + data[i].description + '</p>' +
                                    '</div> ' +
                                    '</div>' +
                                    '</div>';
                                $('#fh5co-blog .dynamic').append(dy_html);
                                //$('#fh5co-blog .dynamic .ddesc').addClass('text-ellipsis');
                            }

                        }
                    })
                },
    //根据新闻id查询
    queryById : function (id) {
        if(!id){
            return;
        }
        $.ajax({
            url: '/front/queryNewsById',
            type: 'post',
            dataType: 'json',
            data : {"id" : newsId}
        }).done(function (data) {
            if (data) {
                $('#fh5co-blog .news').empty();
                var date=getDateObject(data.pubDate);
                var divHtml='<div class="col-md-4 animate-box fadeInUp animated-fast">'+
                    '<div class="fh5co-event">'+
                    '<div class="date text-center"><span>'+date.day+'<br />'+date.month+'</span></div>'+
                    '<h3><a href="#">'+data.title+'</a></h3>'+
                    '<p class="text-ellipsis">'+data.description+'</p>'+
                    '<p><a href="/newsDetail">查看详情</a></p>'
                '</div>'+
                '</div>';
                $('#fh5co-blog .row-padded-mb').append(divHtml);

            }
        })
    }
});
//根据日期获取年月日
function getDateObject(dateStr){
    if(""==dateStr || !dateStr){
        var date=new Date();
    }else{
        var date=new Date(dateStr);
    }
    var year=date.getFullYear();
    var month=date.getMonth();
    var day=date.getDate();
    day=day<10?('0'+day):day;
    var monthArr=['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];
    return {year : year,month : monthArr[month],day : day};
}